-
Notifications
You must be signed in to change notification settings - Fork 311
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(core): calling CheckPoint::insert
with existing block must succeed
#1601
fix(core): calling CheckPoint::insert
with existing block must succeed
#1601
Conversation
BDK currently panics if we start syncing the node while the tip height is still 0, which happens in our usual regtest setup. Here, we make sure to premine *before* starting up the nodes to avoid hitting this panic. While splitting premining and distributing funds in this way is fine (and even makes sense) in most cases, in some cases it's annoying as we wouldn't previously premine at all, but are now required to. So we should eventually drop/revert (at least this part of) this workaround as soon as BDK ships the fix on their end (bitcoindevkit/bdk#1601).
BDK currently panics if we start syncing the node while the tip height is still 0, which happens in our usual regtest setup. Here, we make sure to premine *before* starting up the nodes to avoid hitting this panic. While splitting premining and distributing funds in this way is fine (and even makes sense) in most cases, in some cases it's annoying as we wouldn't previously premine at all, but are now required to. So we should eventually drop/revert (at least this part of) this workaround as soon as BDK ships the fix on their end (bitcoindevkit/bdk#1601).
34fa146
to
e062d58
Compare
BDK currently panics if we start syncing the node while the tip height is still 0, which happens in our usual regtest setup. Here, we make sure to premine *before* starting up the nodes to avoid hitting this panic. While splitting premining and distributing funds in this way is fine (and even makes sense) in most cases, in some cases it's annoying as we wouldn't previously premine at all, but are now required to. So we should eventually drop/revert (at least this part of) this workaround as soon as BDK ships the fix on their end (bitcoindevkit/bdk#1601).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
Previously, we were panicking when the caller tried to insert a block at height 0. However, this should succeed if the block hash does not change.
e062d58
to
2970b83
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 2970b83
ACK 2970b83 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a fine solution but ideally we should ensure bdk never calls CheckPoint::insert
with a block height of 0 for example in electrum and esplora (still looking for a way to reproduce it).
We can add a Panics section to the docs, something like
/// # Panics
///
/// This panics if called with a genesis block that differs from that of `self`.
crates/core/tests/test_checkpoint.rs
Outdated
let cp_chain = CheckPoint::from_block_ids(blocks[..=i].iter().copied()) | ||
.expect("must construct valid chain"); | ||
|
||
for j in 0..i { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for j in 0..i { | |
for j in 0..=i { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self ACK 3ae9ecb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 3ae9ecb
BDK currently panics if we start syncing the node while the tip height is still 0, which happens in our usual regtest setup. Here, we make sure to premine *before* starting up the nodes to avoid hitting this panic. While splitting premining and distributing funds in this way is fine (and even makes sense) in most cases, in some cases it's annoying as we wouldn't previously premine at all, but are now required to. So we should eventually drop/revert (at least this part of) this workaround as soon as BDK ships the fix on their end (bitcoindevkit/bdk#1601).
Description
Previously, we were panicking when the caller tried to insert a block at height 0. However, this should succeed if the block hash does not change.
Notes to the reviewers
For context:
Changelog notice
CheckPoint::insert
to not panic when inserting existing genesis block (same block height and hash).Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingBugfixes:
* [ ] This pull request breaks the existing API